class AlbumManager
  
  def initialize
    @artists=Hash.new{ |hash,key| hash[key]=Hash.new }
  end
  
  def << lyrics
    lyrics.each do |l|
      album=@artists[l.artist][l.album]
      if album.nil?
        album=Album.new({:artist=>l.artist, :title=>l.album})
        @artists[l.artist][l.album]=album
      end
      album << [l]
    end
  end
  
  def albums(artist=nil)
    return @artists[artist].values if artist
    @artists.values
  end
  
end
